const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV);
module.exports = {
    // baseUrl: './',
    publicPath: './',
    assetsDir: 'static',
    productionSourceMap: false,
    devServer: {
        hot: true,
        open: IS_PROD, // 生产环境才使用浏览器自动打开
        https: false,
        port: 8400,
        proxy: {
            '/localApi1': {
                target: process.env.VUE_APP_SRC1,
                changeOrigin: process.env.NODE_ENV === 'development' ? true : false,
                pathRewrite: {
                    '^/localApi1': '/api'
                }
            },
            '/localApi2': {
                target: process.env.VUE_APP_SRC2,
                changeOrigin: process.env.NODE_ENV === 'development' ? true : false,
                pathRewrite: {
                    '^/localApi2': '/api'
                }
            },
            '/localApi3': {
                target: process.env.VUE_APP_SRC3,
                changeOrigin: process.env.NODE_ENV === 'development' ? true : false,
                pathRewrite: {
                    '^/localApi3': '/api'
                }
            },
            '/localApi4': {
                target: process.env.VUE_APP_SRC4,
                changeOrigin: process.env.NODE_ENV === 'development' ? true : false,
                pathRewrite: {
                    '^/localApi4': '/'
                }
            },
            '/localApi5': {
                target: process.env.VUE_APP_SRC5,
                changeOrigin: process.env.NODE_ENV === 'development' ? true : false,
                pathRewrite: {
                    '^/localApi5': '/'
                }
            }
        }
    },
    configureWebpack: config => {
        if (process.env.NODE_ENV === 'production') { // 为生产环境修改配置...
            config.mode = "production";
            config["performance"] = {
                // 入口起点的最大体积
                "maxEntrypointSize": 10000000,
                // 生成文件的最大体积
                "maxAssetSize": 30000000
            }
            config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true;
        } else {
            config.mode = "development";
        }
    },
    pwa: {
        iconPaths: {
            favicon32: 'favicon.ico',
            favicon16: 'favicon.ico',
            appleTouchIcon: 'favicon.ico',
            maskIcon: 'favicon.ico',
            msTileImage: 'favicon.ico'
        }
    }
}